package SortMethod;

import SortHelper.SortHelper;

public class BubbleSort {

    private BubbleSort(){}
    //冒泡排序
    public static <E extends Comparable<E>> void sort(E[] arr){
        for (int i = arr.length - 1; i >= 0; i--) {
            int flag = 1;
            for (int j = 0; j + 1 <= i; j++) {
                if (arr[j].compareTo(arr[j + 1]) > 0){
                    SortHelper.swap(arr,j,j + 1);
                    flag = 0;
                }
            }
            if (flag == 1) break;
        }
    }

}
